package top.abrsm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import top.abrsm.entity.ExpressEntity;
import top.abrsm.mapper.ExpressMapper;
import top.abrsm.service.IExpressService;

@Service
public class ExpressServiceImpl extends ServiceImpl<ExpressMapper, ExpressEntity> implements IExpressService {

    @Override
    public ExpressEntity querySingle (ExpressEntity expressEntity) {
        QueryWrapper<ExpressEntity> queryWrapper = new QueryWrapper<> ();
        if ( StringUtils.isNotBlank ( expressEntity.getId () ) ) {
            queryWrapper.eq ( "id", expressEntity.getId () );
        }
        if ( StringUtils.isNotBlank ( expressEntity.getOrderId () ) ) {
            queryWrapper.eq ( "orderId", expressEntity.getOrderId () );
        }
        expressEntity = baseMapper.selectOne ( queryWrapper );
        return expressEntity;
    }

}
